#ifndef     __TYPE_INFO_H
#define     __TYPE_INFO_H

#include "./byte_view_t.h"
#include <utility>
#include <type_traits>

namespace utils::type_info {

template <typename T>
inline constexpr bool is_codec_type = 
    std::is_integral_v<T> ||
    std::is_same_v<T, byte_view_t>
    ;



inline uint32_t encode_sizeof() {
    return 0;
}

template <typename T, typename... Ts>
inline constexpr uint32_t encode_sizeof(T&& val, Ts&&... ts) {
    using Type = std::decay_t<T>;

    static_assert(is_codec_type<Type>, "codec fail");

    uint32_t size = sizeof (Type);
    if constexpr (std::is_same_v<Type, byte_view_t>) {
        size = 2 + val.len;
    }
    if constexpr (sizeof...(Ts) == 0) {
        return size;
    } else {
        return size + encode_sizeof(std::forward<Ts>(ts)...);
    }
}

enum class Es : uint16_t {};

inline void test() {
    uint8_t a;
    uint16_t b;
    uint32_t c;
    Es e;
    constexpr uint32_t size = encode_sizeof(a, b, c, a, b, b, e);
}

}



#endif
